using SageKing.Studio.Contracts;
using SageKing.Studio.Models;
using SageKing.Studio.Services;
using Microsoft.JSInterop;

namespace SageKing.Studio.MonacoHandlers;

/// <summary>
/// Handles Monaco editor for JavaScript.
/// </summary>
public class JavaScriptMonacoHandler(IJSRuntime jsRuntime, TypeDefinitionService typeDefinitionService)
    : IMonacoHandler
{
    /// <inheritdoc />
    public async ValueTask InitializeAsync(MonacoContext context)
    {
        var editorContext = context.DisplayInputEditorContext;
        var descriptor = editorContext.SelectedExpressionDescriptor;
        
        if(descriptor?.Type != "JavaScript")
            return;

        //var activityTypeName = editorContext.ActivityDescriptor.TypeName;
        //var propertyName = editorContext.InputDescriptor.Name;
        //var definitionId = editorContext.WorkflowDefinition.DefinitionId;
        //var data = await typeDefinitionService.GetTypeDefinition(definitionId, activityTypeName, propertyName); 
        //await jsRuntime.InvokeVoidAsync("monaco.languages.typescript.javascriptDefaults.addExtraLib", data, null);

        throw new NotImplementedException();
    }
}